import '../../utils/dateFormat'
import { toSec } from '../../utils/dateFormat';
var t = wx.createInnerAudioContext()
const app = getApp()
Page({
  data: {
    isFolded: true,
    imgUrl: app.globalData.imgUrl,
    detail: {},//展览详情
    audioList: [],//语音文物列表
  },
  onLoad: function (e) {
    this.getDetail(e.exhibitionId);
  },
  toggleFold: function (t) {
    this.setData({
      isFolded: !this.data.isFolded
    });
  },
  getAudioList: function (t) {
    var _this = this
    wx.showLoading({
      title: "加载中..."
    })
    wx.request({
      url: app.globalData.baseUrl + 'antique3d/front/exhib-detail/' + id,
      header: {
        'content-type': 'application/json',
        'Authorization': wx.getStorageSync('token')
      },
      success(res) {
        _this.setData({
          detail: res.data.data
        })

        wx.hideLoading()
      }
    })
  },
  onUnload: function () {
    t.stop();
  },
  tapClick: function () {
    console.log("ccccccc"), wx.navigateTo({
      url: "/pages/recommend/search"
    });
  },
  getDetail: function (id) {
    var _this = this
    wx.showLoading({
      title: "加载中..."
    })
    wx.request({
      url: app.globalData.baseUrl + 'antique3d/wechat/exhib-code/' + id,
      header: {
        'content-type': 'application/json',
        'Authorization': wx.getStorageSync('token')
      },
      success(res) {
        console.log("---------------------")
        console.log(res.data.data)
        _this.setData({
          detail: res.data.data
        })
        let arr = []
        for (const item of res.data.data.antiqueDetails) {
          console.log(_this.data)
          item.location = _this.data.detail.exhibitionLocation
          item.durationSec = toSec(item.duration)
          arr.push(item)
        }
        _this.setData({
          audioList: arr
        })
        wx.hideLoading()
      }
    })
  }
});